<%--
 *  File:    uploadConfigSummary.jsp
 *  @Author: jeanhuang
 *  Date:    2013/15/30
 *
 *  Copyright (C) 2000 - 2010 Oval Technologies, Inc.
 *  All rights reserved. 
 *
 *  This software is the confidential and proprietary information of Oval 
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>


<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>     
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>

<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>

<% //--------------------------------------  setting logger --%>
<%
  	Category cat = Category.getInstance("jsp.uploadConfigSummary"); 

  //init param
  String strModuleName = "IMG";
  String privilegeCode = "IMG0303";
  String contextPath = request.getContextPath();
  String strTableName = "v_uploadconfigsummary";
  if(session.getAttribute("uploadconfigid")!=null){
	  session.removeAttribute("uploadconfigid");
  }
%>
<% //--------------------------------------  include files list --%>
<%@ include file="/inc/Security.inc" %>
<%@ include file="/inc/PageDefault.inc" %>
<%@ include file="/inc/LocationDefault.inc" %>

<html>
<head>
<title>uploadConfigSummary</title>
<PageFlow:CheckPageFlow pageName="p_uploadconfigsummary"/>
<link rel="stylesheet" href="<%=contextPath %>/css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="<%=contextPath %>/css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/FuncLib.js"></script>
<%@ include file="/inc/SummaryDivision.inc" %>
<script>

function clickRow(id,status, rownum,code)
{
  document.cform.uploadconfigid.value = id;
  document.cform.status.value = status;
  document.cform.rownum.value = rownum;
  document.cform.code.value = code;
}

function page_delete()
{
  var id = document.cform.uploadconfigid.value;

  if(id == null || id.length == 0 || id == "" || id == "-1")
    return;

  if(!confirm("<%= message.getMessageDesc("ARE_YOU_SURE_DEL")%>")) return;
  
  document.cform.actionname.value = "delete";
   document.cform.target = "_self";
  isRunning = true;
  document.cform.submit();
  
}

function page_edit()
{
  var uploadconfigid = document.cform.uploadconfigid.value;
  if(uploadconfigid == null || uploadconfigid.length == 0 || uploadconfigid == "" || uploadconfigid == "-1")
    return;
      var link ="uploadconfigfrm.jsp?<%= OvalTools.randomURL() %>&uploadconfigid=" + uploadconfigid+"&displayflag=edit";
	 self.location.href=link;
  
}

function page_new()
{
	var link='uploadconfigfrm.jsp?<%= OvalTools.randomURL() %>&flag=new';
	self.location.href=link;
}

function page_config(){
	if(confirm("<%=message.getMessageDesc("CONFIRM_CREATE_CONFIG")%>")){
		var status = document.cform.status.value;
		if(status==80){
			alert("<%= message.getMessageDesc("Upload_Has_Config_Finish")%>");
		    return;
		}
	      document.cform.actionname.value = "changestatus";
	      document.cform.target = "_self";
		  document.cform.submit();
	}
	
}

function page_create(){
		var status = document.cform.status.value;
		if(status != 80){
			alert("<%= message.getMessageDesc("ONLY_FINSH_CAN_CREATE")%>");
			return;
		}
	    document.cform.actionname.value = "createmodel";
	    document.cform.target = "_self";
		document.cform.submit();
}

function page_summary(actionvalue,orderbyname)
{
  var editform = summaryPrepare(cform,actionvalue,orderbyname);
  editform.action = "uploadConfigSummary.jsp?<%= OvalTools.randomURL() %>";
  editform.target = "_self";
  isRunning = true;
  editform.submit();  
}

function page_detail(id,rownum){
	var link ="uploadconfigfrm.jsp?<%= OvalTools.randomURL() %>&uploadconfigid=" + id+"&displayflag=view";
	 self.location.href=link;
}
</script>
</head>
<body>
<% //--------------------------------------  page location --%>
	<%@ include file="/inc/PageLocation.inc" %>
<table width="100%" cellspacing="0" border="0" cellpadding="0">
<form name="cform" method="post" action="<%=contextPath %>/Dispatcher"  target="_parent">
	<input type="hidden" name="pagename" value="p_uploadconfigsummary">
	<input type="hidden" name="actionname">
	<input type="hidden" name="dcperiodid">
   <tr>
    <td> 
      <table width="100%" border="0" cellspacing="0">  
         <%@ include file="/inc/SummarySearch.inc" %>
       </table>
    </td>
  </tr>
  <tr> 
    <td> 
      <table width="100%" border="1" cellpadding="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0" align="center">
         <tr  class="deepblue-left"> 
            <td width="4%" class="title_center">&nbsp;</td>
            
            <td class="title_center"><a href="javascript:page_summary('orderby','name')"><%= label.getLabelName("L_ConfigName") %></a></td>
            <td width="8%" class="title_center"><a href="javascript:page_summary('orderby','code')"><%= label.getLabelName("L_ConfigCode") %></a></td>
            <td width="8%" class="title_center"><a href="javascript:page_summary('orderby','tablename')"><%= label.getLabelName("L_VtableName") %></a></td>
            <td width="8%" class="title_center"><a href="javascript:page_summary('orderby','pkcolumnname')"><%= label.getLabelName("L_Pkname") %></a></td>
            <td width="13%" class="title_center"><a href="javascript:page_summary('orderby','startrow')"><%= label.getLabelName("L_BeginLine") %></a></td>
            <td width="15%" class="title_center"><a href="javascript:page_summary('orderby','tactics')"><%= label.getLabelName("L_Tactics") %></a></td>
            <td width="5%" class="title_center"><a href="javascript:page_summary('orderby','tacticsproname')"><%= label.getLabelName("L_TacticsProcess") %></a></td>
            <td width="12%" class="title_center"><a href="javascript:page_summary('orderby','status')"><%= label.getLabelName("L_Status") %></a></td>
            <td width="12%" class="title_center"><a href="javascript:page_summary('orderby','tableseq')"><%= label.getLabelName("L_SequenceSetting") %></a></td>
            
         </tr>
         <%
             int j = 0;
             String strClassType = new String(); 
             String sDefaultCode = "";
             Integer nDefaultConfigid = new Integer(-1); 
             Integer nDefaultStatusid = new Integer(-1);
             boolean bHasChecked = false;
             Vector totalsummary = (Vector)pageContext.getAttribute("totalsummary");
             if(totalsummary == null) totalsummary = new Vector();
  
          %>
          <logic:iterate id="summary" collection="<%= totalsummary %>">                      
         <%
            HashMap summaryMap = (HashMap)pageContext.getAttribute("summary");
            if(summaryMap == null) summaryMap = new HashMap();
            String strIsChecked = new String("");
            String strIsDisabled = new String("");
          
            if(j%2 == 1){
              strClassType = "td-listrom";             
            }else{                    
              strClassType = "";
            }
            
            if(!bHasChecked)
        	{
          		strIsChecked = "Checked";                       
          		bHasChecked = true;      
          		nDefaultConfigid = (Integer)summaryMap.get("uploadconfigid");                 
          		nDefaultStatusid = (Integer)summaryMap.get("status");   
          		sDefaultCode = (String)summaryMap.get("code");
        	}
            
           
            j++;     
          %>
           <tr onmouseover="this.className='tr-over'" onmouseout="this.className='<%=JspHelper.filterNull(strClassType)%>'"  onClick="javascript:radiotrue('radio<%=JspHelper.filterNull(j)%>');clickRow('<custom:write property="uploadconfigid" name="summary"/>','<custom:write property="status" name="summary"/>','<%=j + "" %>','<custom:write property="code" name="summary"/>')" class="<%=JspHelper.filterNull(strClassType)%>">
            <td class="td_center">
              <input class="normalradio" id="radio<%=JspHelper.filterNull(j )%>" type="radio" name="checkdept" value="" <%=JspHelper.filterNull( strIsChecked)%> <%=strIsChecked %>>
            </td>
            <td class="td_center"><A onclick="page_detail('<custom:write property="uploadconfigid" name="summary"/>','<%=j %>')"><custom:write property="name" name="summary" nbsp="true" /></A></td>
            <td class="td_center"><custom:write property="code" name="summary" nbsp="true" /></td>
            <td class="td_center"><custom:write property="tablename" name="summary" nbsp="true" /></td>
            <td class="td_center"><custom:write property="pkcolumnname" name="summary" nbsp="true" /></td>
            <td class="td_center"><custom:write property="startrow" name="summary" nbsp="true"/></td>
            <td class="td_center"><custom:write property="tactics" name="summary" nbsp="true" dictType="uploadtactics"/></td>
            <td class="td_center"><custom:write property="tacticsproname" name="summary" nbsp="true" /></td>
            <td class="td_center"><custom:write property="status" name="summary" nbsp="true" dictType="Status"/></td>
            <td class="td_center"><custom:write property="tableseq" name="summary" nbsp="true" /></td>
          </tr>
          </logic:iterate>
          <%//---------------set default value-------------------- %>
          <input type="hidden" name="uploadconfigid" value="<%=JspHelper.filterNull( nDefaultConfigid )%>" />
          <input type="hidden" name="code" value="<%=JspHelper.filterNull( sDefaultCode )%>" />
          <input type="hidden" name="status" value="<%=JspHelper.filterNull( nDefaultStatusid )%>"  />
          <input type="hidden" name="rownum" value="1">
      <% //--------------------------------------  flipping page --%>
      <%@ include file="/inc/SummaryAction.inc" %>
      </table>
      <table width="100%" cellspacing="0" cellpadding="0">
        <tr> 
          <td class="summary_top"></td>
        </tr>
        <tr> 
          <td class="td_center">
            <a onclick="page_new()"><custom:button type="1" label="L_New" imgsrc="new.gif" border="0" style="width:60"/></a>
            <a onclick="page_edit()"><custom:button type="1" label="L_Edit" imgsrc="edit.gif" border="0" style="width:60"/></a>
            <a onclick="page_delete()"><custom:button type="1" label="L_Delete" imgsrc="delete.gif" border="0" style="width:60"/></a>
            <a onclick="page_config()"><custom:button type="1" label="L_Config" imgsrc="delete.gif" border="0" style="width:60"/></a>
            <a onclick="page_create()"><custom:button type="1" label="L_CreateModelFile" imgsrc="delete.gif" border="0" style="width:80"/></a>
          </td>
        </tr>
      </table>
    </td>
  </tr>
  </form>
</table>
</body>
</html>